﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HeroFightConfig
{
    //英雄配置
    public static Dictionary<int, HeroBattleConfig> s_dicConfig = new Dictionary<int, HeroBattleConfig>();

    public static void AddHeroBattleConfig(HeroBattleConfig data)
    {
        if (!s_dicConfig.ContainsKey(data.pId))
        {
            s_dicConfig.Add(data.pId, data);
        }
    }

    public static HeroBattleConfig GetHeroBattleConfig(int pId)
    {
        if (s_dicConfig.ContainsKey(pId))
        {
            return s_dicConfig[pId];
        }

        return null;
    }

    //子弹配置
    public static Dictionary<int, BulletConfig> s_dicBullet = new Dictionary<int, BulletConfig>();
    public static void AddBulletConfig(BulletConfig data)
    {
        if (!s_dicBullet.ContainsKey(data.pId))
        {
            s_dicBullet.Add(data.pId, data);
        }
    }

    public static BulletConfig GetBulletConfig(int pId)
    {
        if (s_dicBullet.ContainsKey(pId))
        {
            return s_dicBullet[pId];
        }
        return null;
    }

    //特效配置
    public static Dictionary<int, EffectVoConfig> s_dicEffectVo = new Dictionary<int, EffectVoConfig>();
    public static void AddEffectVo(EffectVoConfig data)
    {
        if (!s_dicEffectVo.ContainsKey(data.pId))
        {
            s_dicEffectVo.Add(data.pId, data);
        }
    }
    public static EffectVoConfig GetEffectVo(int pId)
    {
        if (s_dicEffectVo.ContainsKey(pId))
        {
            return s_dicEffectVo[pId];
        }
        return null;
    }


    public static void InitHeroBattleConfig()
    {
        AddHeroBattleConfig(new HeroBattleConfig(1000, "HeroFight/shouyeren/Prefab/shouyeren", 1, 6, 10, 10, 2000,true,0.5f));
        AddHeroBattleConfig(new HeroBattleConfig(1001, "HeroFight/heianqishi/Prefab/heianqishi", 1, 6, 10, 10, 0,false,0));
        AddHeroBattleConfig(new HeroBattleConfig(1002, "HeroFight/kuangaoqishi/Prefab/kuangaoqishi", 1, 6, 10, 10, 0,false,0));
        AddHeroBattleConfig(new HeroBattleConfig(1003, "HeroFight/lieyannvshen/Prefab/lieyannvshen", 1, 6, 10, 10, 0,false,0));
        AddHeroBattleConfig(new HeroBattleConfig(1004, "HeroFight/handijingang/Prefab/handijingang", 1, 6, 10, 10, 0,false,0));
        AddHeroBattleConfig(new HeroBattleConfig(1005, "HeroFight/wutouqishi/Prefab/wutouqishi", 1, 6, 10, 10, 0,false,0));

        AddBulletConfig(new BulletConfig(0, 5, 10, 10, 0, 0, 0,Vector3.zero,1));
        AddBulletConfig(new BulletConfig(2000, 15, 10, 10, 0, 3001, 3002,new Vector3(0,1.3f,0),2));

        AddEffectVo(new EffectVoConfig(3000, "HeroFight/FlyItem/Bullet_born", 3, true));
        AddEffectVo(new EffectVoConfig(3001, "HeroFight/FlyItem/Bullet", 0, false));
        AddEffectVo(new EffectVoConfig(3002, "HeroFight/FlyItem/Bullet_hit", 3, true));
    }
}

public class HeroBattleConfig
{
    public int pId = 0;
    //模型路径
    public string modelPath = "";
    //近身攻击动作时候的攻击范围
    public float attackRange = 0;
    //退回时候的速度
    public float runSpeed = 5;
    //加速度
    public float acceleration = 10;
    //最大速度
    public float maxSpeed = 10;
    //普攻远程
    public int remotePid = 0;
    //是近程还是远程
    public bool isRemote = false;
    //射出剑的延迟时间
    public float shootDelay = 0;

    public HeroBattleConfig(int id,string modelPath,float arange,float runSpeed,float acc,float maxSpeed,int remotePid,bool bremote,float shootDelay)
    {
        this.pId = id;
        this.modelPath = modelPath;
        this.attackRange = arange;
        this.runSpeed = runSpeed;
        this.acceleration = acc;
        this.maxSpeed = maxSpeed;
        this.remotePid = remotePid;
        this.isRemote = bremote;
        this.shootDelay = shootDelay;
    }
}

public class BulletConfig
{
    public int pId = 0;

    //射出瞬间
    //public int bornEff = 0;
    //飞行中
    public int flyEff = 0;
    //击中
    public int hitEff = 0;
    //子弹实体距离父级的位置
    public Vector3 offset;
    //子弹的运动方式
    public int moveType;

    public float flySpeed = 5;
    public float acceleration = 10;
    public float maxSpeed = 10;
    public BulletConfig()
    {

    }
    public BulletConfig(int id, float speed, float acc, float max, int born, int fly, int hit,Vector3 offset,int moveType)
    {
        this.pId = id;
        //this.bornEff = born;
        this.flyEff = fly;
        this.hitEff = hit;
        this.flySpeed = speed;
        this.acceleration = acc;
        this.maxSpeed = max;
        this.offset = offset;
        this.moveType = moveType;
    }
}

public class EffectVoConfig 
{
    public int pId = 0;
    public string modelPath;
    public float duration;
    public bool autoDel;
    public EffectVoConfig(int pId, string modelPath, float duration, bool autoDel)
    {
        this.pId = pId;
        this.modelPath = modelPath;
        this.duration = duration;
        this.autoDel = autoDel;
    }
}